#include <stdio.h>

#define ADC_RANGE    5.0
#define ADC_PER_VOLT (65536/ADC_RANGE)

#define NULL         10      /* psi   */
#define RANGE        5       /* psi   */
#define OFFSET       .301    /* volts */
#define SPAN         (3.012-OFFSET)   /* volts */



int main( int argc, char *argv[] )
{
  float i, volts, span, range, offset, null, pres;


  printf ( "const U_INT16   Atm_Pres_Table[] = { /* 80 Dcm2/IU */\n");

  for ( i = 0.0 ; i < ADC_RANGE ; i += ADC_RANGE/256.0 )
  {
      volts = i * ADC_PER_VOLT;            /* ovltage in adc counts */
      span  = SPAN * ADC_PER_VOLT;         /* sensor voltage span in adc counts */
      range = RANGE * 68947.57 / 80;       /* range in iu */
      offset= OFFSET * ADC_PER_VOLT;       /* sensor offset in adc counts */
      null  = NULL* 68947.57 / 80;         /* pres offset in iu */

      pres =  null + ( volts - offset ) * range / span ;
      
      printf ( " /* %3.2f  %04hx */  0x%-hx, /* %5.3f */\n",
                         i, (int)(i*ADC_PER_VOLT),
                         (int) pres,
                         pres * 80 / 68947.57 );
  }


      volts = ADC_RANGE * ADC_PER_VOLT;    /* ovltage in adc counts */
      span  = SPAN * ADC_PER_VOLT;         /* sensor voltage span in adc counts */
      range = RANGE * 68947.57 / 80;       /* range in iu */
      offset= OFFSET * ADC_PER_VOLT;       /* sensor offset in adc counts */
      null  = NULL* 68947.57 / 80;         /* pres offset in iu */

      pres =  null + ( volts - offset ) * range / span ;
      
      printf ( " /* %3.2f  %04hx */  0x%-hx  }; /* %5.3f */\n",
                         i, (int)(i*ADC_PER_VOLT),
                         (int) pres,
                         pres * 80 / 68947.57 );

   return 0;

}
